package 集合框架.Set.课后作业.M3;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 提示：
 * 1.编写一个Student类
 * 2.在主方法main()中使用Collections工具类sort()方法对ArrayList进行排序.
 * Collections.sort(arr, new Comparator<Student>() {
 *             @Override
 *             public int compare(Student o1, Student o2) {
 *                 int result = (int)(o2.getSorce() - o1.getSorce());
 *                 if(result==0){
 *                     result = o2.getAge()-o1.getAge();
 *                 }
 *                 return  result;
 */
public class Test {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();

        students.add(new Student("张三", 20, 95));
        students.add(new Student("王八", 22, 95));
        students.add(new Student("王五", 23, 88));
        students.add(new Student("田七", 24, 150));
        Collections.sort(students);
        for (Student student : students) {
            System.out.println(student.toString());
        }

    }
}
